/*
 *  This file is part of Cha++ers.
 *
 *  Cha++ers is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  Cha++ers is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with Cha++ers.  If not, see <http://www.gnu.org/licenses/>.
*/

#include <ctype.h>
#include <stdio.h>
#include "text.h"

string replaceText(string buf, string fstr, string rstr)
{
	int fslen = fstr.size();
	int rslen = rstr.size();
	size_t it = buf.find(fstr);
	while (it != std::string::npos) {
		buf = buf.replace(it,fslen,rstr);
		it = buf.find(fstr,it+rslen);
	}
	return buf;
}


string stripBadChars(string buf)
{
	size_t i = 0;
	while (i < buf.size()) {
		while (buf[i] < 0)buf = buf.erase(i,i+1);
		i ++;
	}
	return buf;
}
